package com.accesshollywood.viewFiltering;

import java.util.LinkedHashSet;

import com.accesshollywood.grfxOrdering.basics.Destinations;
import com.accesshollywood.grfxOrdering.basics.GraphicTypes;
import com.accesshollywood.grfxOrdering.basics.Users;
import com.accesshollywood.indexables.Destination;
import com.accesshollywood.indexables.GraphicType;
import com.accesshollywood.indexables.User;

public class ViewFiltering {
	public static LinkedHashSet<ViewFilterGroup>	viewFilterGroups;

	public ViewFiltering() {
		viewFilterGroups = createGroups();
	}

	public LinkedHashSet<ViewFilterGroup> createGroups() {
		LinkedHashSet<ViewFilterGroup> groups = new LinkedHashSet<ViewFilterGroup>();

		ViewFilterGroup vfgProgress = new ViewFilterGroup("Progress");
		ViewFilterGroup vfgStatus = new ViewFilterGroup("Status");
		ViewFilterGroup vfgDueDate = new ViewFilterGroup("Due Date");
		ViewFilterGroup vfgRequirements = new ViewFilterGroup("Required Approvals");
		ViewFilterGroup vfgShow = new ViewFilterGroup("Show");
		ViewFilterGroup vfgBlock = new ViewFilterGroup("Block");
		ViewFilterGroup vfgGraphicType = new ViewFilterGroup("GraphicType");
		ViewFilterGroup vfgDestination = new ViewFilterGroup("Destination");
		ViewFilterGroup vfgArtist = new ViewFilterGroup("Artist");
		ViewFilterGroup vfgResearcher = new ViewFilterGroup("Researcher");
		ViewFilterGroup vfgPhotoEdit = new ViewFilterGroup("PhotoEdit");
		ViewFilterGroup vfgFootage = new ViewFilterGroup("Footage");
		ViewFilterGroup vfgLegal = new ViewFilterGroup("Legal");
		ViewFilterGroup vfgProducer = new ViewFilterGroup("Producer");
		ViewFilterGroup vfgArchive = new ViewFilterGroup("Archive");

		groups.add(vfgProgress);
		groups.add(vfgStatus);
		// groups.add(vfgDueDate);
		groups.add(vfgRequirements);
		groups.add(vfgShow);
		groups.add(vfgBlock);
		groups.add(vfgGraphicType);
		groups.add(vfgDestination);
		groups.add(vfgArtist);
		groups.add(vfgResearcher);
		groups.add(vfgPhotoEdit);
		groups.add(vfgFootage);
		groups.add(vfgLegal);
		groups.add(vfgProducer);
		groups.add(vfgArchive);

		int id = 0;

		vfgProgress.add(new ViewFilterTemplate(id++, "Open", "(complete=0 AND closed=0 AND (idArtist=0 OR idArtist=3))"));
		vfgProgress.add(new ViewFilterTemplate(id++, "In Progress", "(complete=0 AND closed=0 AND (idArtist!=0 OR idArtist!=3))"));
		vfgProgress.add(new ViewFilterTemplate(id++, "Completed", "(complete=1)"));
		vfgProgress.add(new ViewFilterTemplate(id++, "Closed", "(closed=1)"));

		vfgStatus.add(new ViewFilterTemplate(id++, "Researched", "(needsResearch=1 AND apprResearch=1)"));
		vfgStatus.add(new ViewFilterTemplate(id++, "Not Researched", "(apprResearch=0)"));
		vfgStatus.add(new ViewFilterTemplate(id++, "PhotoEdit", "(needsPhotoEdit=1 AND apprPhotoEdit=1)"));
		vfgStatus.add(new ViewFilterTemplate(id++, "No Photos Yet", "(apprPhotoEdit=0)"));
		vfgStatus.add(new ViewFilterTemplate(id++, "Footage", "(needsFootage=1 AND apprFootage=1)"));
		vfgStatus.add(new ViewFilterTemplate(id++, "No Footage Yet", "(apprFootage=0)"));
		vfgStatus.add(new ViewFilterTemplate(id++, "Legal", "(needsLegal=1 AND apprLegal=1)"));
		vfgStatus.add(new ViewFilterTemplate(id++, "Not Legal Approved", "(apprLegal=0)"));

		vfgRequirements.add(new ViewFilterTemplate(id++, "Research", "(needsResearch=1)"));
		vfgRequirements.add(new ViewFilterTemplate(id++, "PhotoEdit", "(needsPhotoEdit=1)"));
		vfgRequirements.add(new ViewFilterTemplate(id++, "Footage", "(needsFootage=1)"));
		vfgRequirements.add(new ViewFilterTemplate(id++, "Legal", "(needsLegal=1)"));

		vfgShow.add(new ViewFilterTemplate(id++, "Access", "(idShowName=1)"));
		vfgShow.add(new ViewFilterTemplate(id++, "Live", "(idShowName=2)"));
		vfgShow.add(new ViewFilterTemplate(id++, "Special", "(idShowName=3)"));
		vfgShow.add(new ViewFilterTemplate(id++, "Rnd", "(idShowName=4)"));

		vfgBlock.add(new ViewFilterTemplate(id++, "A", "(block='A')"));
		vfgBlock.add(new ViewFilterTemplate(id++, "B", "(block='B')"));
		vfgBlock.add(new ViewFilterTemplate(id++, "C", "(block='C')"));
		vfgBlock.add(new ViewFilterTemplate(id++, "D", "(block='D')"));
		vfgBlock.add(new ViewFilterTemplate(id++, "E", "(block='E')"));
		vfgBlock.add(new ViewFilterTemplate(id++, "F", "(block='F')"));
		vfgBlock.add(new ViewFilterTemplate(id++, "G", "(block='G')"));

		for (GraphicType currGraphicType : GraphicTypes.allGraphicTypes.values()) {
			vfgGraphicType.add(new ViewFilterTemplate(id++, currGraphicType.getName(), "(idGraphicType='"+ currGraphicType.getId() + "')"));
		}

		for (Destination currDestination : Destinations.allDestinations.values()) {
			vfgDestination.add(new ViewFilterTemplate(id++, currDestination.getName(), "(idDestination='"+ currDestination.getId() + "')"));
		}

		for (Object currArtist : Users.artistUsers.toArrayList()) {
			vfgArtist.add(new ViewFilterTemplate(id++, ((User) currArtist).getFullName(), "(idArtist=" + ((User) currArtist).getId() + ")"));
		}

		for (Object currResearcher : Users.researchUsers.toArrayList()) {
			vfgResearcher.add(new ViewFilterTemplate(id++, ((User) currResearcher).getFullName(), "(idResearcher=" + ((User) currResearcher).getId() + ")"));
		}

		for (Object currPhotoEdit : Users.photoEditUsers.toArrayList()) {
			vfgPhotoEdit.add(new ViewFilterTemplate(id++, ((User) currPhotoEdit).getFullName(), "(idPhotoEdit=" + ((User) currPhotoEdit).getId() + ")"));
		}

		for (Object currFootage : Users.footageUsers.toArrayList()) {
			vfgFootage.add(new ViewFilterTemplate(id++, ((User) currFootage).getFullName(), "(idFootage=" + ((User) currFootage).getId() + ")"));
		}

		for (Object currLegal : Users.legalUsers.toArrayList()) {
			vfgLegal.add(new ViewFilterTemplate(id++, ((User) currLegal).getFullName(), "(idLegal=" + ((User) currLegal).getId() + ")"));
		}

		for (Object currProducer : Users.producerUsers.toArrayList()) {
			vfgProducer.add(new ViewFilterTemplate(id++, ((User) currProducer).getFullName(), "(idProducer=" + ((User) currProducer).getId() + ")"));
		}

		vfgArchive.add(new ViewFilterTemplate(id++, "Archived", ""));

		return groups;
	}
}
